<template>
    <div class="son-box">
        <h3>子组件</h3>
        <button @click="sendData">沟通</button>
        <h4>收到父组件传过来的{{money}} 为了感谢爷爷给的钱,
            <router-link to="/basket">
                去买菜
            </router-link>
            <a href="#/basket">
                去买菜
            </a>
            <button @click="$router.push('/basket')">去买菜</button>
        </h4>
        <button @click="$store.commit('setNum',100)">给家族财产放钱</button>
    </div>
</template>

<script>
    export default {
        props:['money'],
        created(){
            //组件实例上的$parent属性就是父组件实例；
            //$root是根实例(祖先)
            // console.log(
            //     this.$parent.$parent,
            //     this.$root
            // );
        },
        methods:{
            sendData(){this.$store
                window.eventBus.$emit('get-data','祖爷爷,你好')
            }
        },
        data(){
            return{
                name:"孙子组件"
            }
        }
    }
</script>

<style lang="sass" scoped>
.son-box
    margin: 10px
    padding: 10px
    border: 3px solid purple
</style>